<template>
  <div class="app-container">
    <div class="item2">
      <div class="header">
        <div class="title1">
          <i class="el-icon-data-analysis"></i><span>小Tob内复核工作量</span>
        </div>
        <div class="backB">
          <img src="@/assets/images/back.png" alt="" @click="goBack" />
        </div>
      </div>
      <div class="formCenter">
        <el-form
          :model="queryParams"
          size="large"
          :inline="true"
          ref="queryForm"
          label-width="120px"
        >
          <el-form-item label="时间:" prop="addTime">
            <el-date-picker
              v-model="addTime"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="medium"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button
              type="primary"
              plain
              icon="el-icon-download"
              size="medium"
              @click="handleExport"
              >导出</el-button
            >
          </el-form-item>
        </el-form>
      </div>
      <el-table
        :data="tableData"
        border
        height="680"
        v-loading="loading"
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        :header-cell-style="{ background: '#1890ff', color: '#ffffff' }"
      >
        <!-- <el-table-column align="center" prop="floor" label="楼层">
        </el-table-column> -->
        <el-table-column align="center" prop="roledescr" label="角色名称">
        </el-table-column>
        <el-table-column align="center" prop="username" label="用户名">
        </el-table-column>
        <el-table-column align="center" prop="checkwho" label="账号">
        </el-table-column>
        <el-table-column align="center" prop="pxNum" label="拼箱数">
        </el-table-column>
        <el-table-column align="center" prop="lineNum" label="品规数">
        </el-table-column>
        <el-table-column align="center" prop="djs" label="单据数">
        </el-table-column>
        <el-table-column align="center" prop="zxNum" label="周转箱数">
        </el-table-column>
        <el-table-column align="center" prop="num" label="数量">
        </el-table-column>
      </el-table>
      <div>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="handleQuery"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { getlzBbList } from "@/api/subSystem/continer";
import { getcheckCarPassword } from "@/api/subSystem/continer";
export default {
  dicts: ["floor_type", "taskprocess_type", "taskprocessmsg_type"],
  data() {
    return {
      // 密码验证
      centerDialogVisible: false,
      passForm: {
        pass: null,
        account: null,
      },
      passrules: {
        // pass: [{ validator: passwordError, trigger: "blur" }],
        pass: [{ required: true, message: "请输入密码", trigger: "blur" }],
        account: [{ required: true, message: "请输入账号", trigger: "blur" }],
      },
      // 总条数
      total: 0,
      addTime: [
        new Date().toISOString().split("T")[0],
        new Date().toISOString().split("T")[0],
      ],
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        // addTime: [],
      },
      tableData: [],
      loading: false,
      // 笼车号传参
      boxNumber: null,
    };
  },
  mounted() {
    // this.handleQuery();
  },
  methods: {
    goBack() {
      this.$router.push("/subSystem1");
    },
    handleQuery() {
      this.$refs.queryForm.validate((valid) => {
        if (valid) {
          this.queryParams.params = {};
          if (null != this.addTime && "" != this.addTime) {
            this.queryParams.params["beginTime"] = this.addTime[0];
            this.queryParams.params["endTime"] = this.addTime[1];
          }
          console.log(this.queryParams);
          if (
            this.queryParams.params["beginTime"] &&
            this.queryParams.params["endTime"]
          ) {
            this.loading = true;
            getlzBbList(this.queryParams).then((res) => {
              this.tableData = res.rows;
              this.total = res.total;
              this.loading = false;
            });
          } else {
            this.loading = false;
            this.$message.error("请先选择任务时间");
          }
        }
      });
    },
    handleExport(){
        this.download(
        "system/lzBb/export",
        {
          ...this.queryParams,
        },
        `post_${new Date().getTime()}.xlsx`
      );
    }
  },
};
</script>
<style lang="scss" scoped>
.app-container {
  .el-icon-data-analysis::before {
    color: #00d9ff;
    margin-right: 8px;
  }
  .title1 {
    font-size: 16px;
    // margin-bottom: 15px;
    color: #808080;
    width: 200px;
    padding: 5px;
    border-bottom: 1px dotted #8ddfff;
  }
  .header {
    margin-top: -10px;
    margin-bottom: 20px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .el-date-editor.el-input,
    .el-date-editor.el-input__inner {
      width: 220px;
      margin-right: 20px;
    }

    .backB {
      cursor: pointer;

      img {
        width: 20%;
      }
    }
  }
  .formCenter {
    height: 62px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .footer {
    margin-top: 20px;
    width: 100%;
    min-height: 200px;
  }
  .el-select {
    width: 240px;
  }
}
</style>